package com.crazybytex.fragment.jsontyperesolver;

import com.alibaba.fastjson.JSON;

/**
 * @Author 本文作者 程序员潇然 疯狂的字节X https://www.crazybytex.com/
 * @Description 见Tester 注释
 **/
public class Message {
    private String msg;
    private String code;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Message{");
        sb.append("msg='").append(msg).append('\'');
        sb.append(", code='").append(code).append('\'');
        sb.append('}');
        return sb.toString();
    }

    public static void main(String[] args) {
        Message message = new Message();
        message.code = "0";
        message.msg = "message ";
        System.out.println(JSON.toJSONString(message));

        Message1 message1 = new Message1();
        message1.setCode("1");
        message1.setMsg("msg0-1");
        message1.setMessage1("msg1  1");
        System.out.println(JSON.toJSONString(message1));


        Message2 message2 = new Message2();
        message2.setCode("2");
        message2.setMsg("msg0-2");
        message2.setMessage2("msg2  2");
        message2.setMessage2Other("meg2-other");
        System.out.println(JSON.toJSONString(message2));


        MessageWrapper messageWrapper = new MessageWrapper();
        messageWrapper.setType("1");
        messageWrapper.setData(message1);
        System.out.println(JSON.toJSONString(messageWrapper));

        messageWrapper.setType("2");
        messageWrapper.setData(message2);
        System.out.println(JSON.toJSONString(messageWrapper));


    }
}
